using PKGames.Audio;
using PKGames.Localization;
//using PKGames.Store;
using UnityEngine;
using UnityEngine.UI;

namespace PKGames
{
	public class SettingsOptionsController : MonoBehaviour
	{
		[SerializeField]
		private Button _contactUsButton;

		[SerializeField]
		private Text _contactUsText;

		[SerializeField]
		private Button _termsOfUseButton;

		[SerializeField]
		private Text _termsOfUseText;

		[SerializeField]
		private Button _restorePurchaseButton;

		[SerializeField]
		private Text _restorePurchaseText;

		private const string ContactUsKey = "ContactUsKey";

		private const string TermsOfServiceKey = "TermsOfServiceKey";

		private const string RestorePurchaseKey = "ResetStageKey";

		private void Start()
		{
			_contactUsButton.onClick.AddListener(OpenSupport);
			_termsOfUseButton.onClick.AddListener(OpenTermsOfUse);
			_restorePurchaseButton.onClick.AddListener(RestorePurchase);
			_contactUsText.text = MonoSingleton<LocationProvider>.Instance.GetLocalizedString("ContactUsKey");
			_termsOfUseText.text = MonoSingleton<LocationProvider>.Instance.GetLocalizedString("TermsOfServiceKey");
			_restorePurchaseText.text = MonoSingleton<LocationProvider>.Instance.GetLocalizedString("ResetStageKey");
		}

		private void OpenSupport()
		{
			MonoSingleton<AudioManager>.Instance.Play("select_simple");
			Application.OpenURL("http://support.playkidsapp.com/");
		}

		private void OpenTermsOfUse()
		{
			MonoSingleton<AudioManager>.Instance.Play("select_simple");
			string str = "https://assets.playkidsapp.com/voxel_app/html/tos-";
			str += "android";
			str += "-";
			string language = MonoSingleton<LocationProvider>.Instance.GetLanguage();
			str = ((!(language == "pt")) ? (str + "en") : (str + "pt"));
			str += ".html";
			Application.OpenURL(str);
		}

		private void RestorePurchase()
		{
			MonoSingleton<AudioManager>.Instance.Play("select_simple");
			//StoreManager.Instance.RestoreTransactionsIos();
		}
	}
}
